<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>中国福利彩票</title>
<link href="css/style.css" type="text/css" rel="stylesheet" />
	<link rel="icon" href="images/favicon.png" type="image/x-icon"/>
<script src="js/jquery-1.7.2.min.js"></script>

</head>

<body onload="load()">
	<div class="Header">
    	<div class="width1200">
        	<div class="left H_logo"><img src="images/logo.png" width="200" /></div>
            <div class="right H_right">  <a href="Login.html">登录</a> </div>
            <div class="clear"></div>
        </div>
    </div>
	
    <div class="width1200">
    	<div class="Register">
        	
            <div class="REG_stpe"><img src="images/Zimg2.png" width="503" /></div>
            
            <div class="REG_Sone">
            	<table width="100%" border="0" cellspacing="15" cellpadding="0">
                  <tr>
                    <td width="20%" align="right">姓名</td>
                    <td width="80%"><input type="text" class="RE1_t1" id="name" /></td>
                  </tr>
                  <tr>
                    <td align="right">性别</td>
                    <td>
                    	<select name="" class="RE1_sex" id="sex">
                    	  <option value="1">男</option>
                    	  <option value="0">女</option>
                    	</select>
                    </td>
                  </tr>
                  <tr>
                    <td align="right">身份证号</td>
                    <td><input type="text" class="RE1_t2" id="idCard"/></td>
                  </tr>
                  <tr>
                    <td align="right">银行</td>
                    <td>
                    	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table1">
                          <tr>
                            <td width="40%">
                            	<select name="" class="RE_St2" id="bank">
                                    
                                </select>
                            </td>
                            <td width="20%" align="center" >归属地</td>
                            <td width="40%">
                            	<select name="" class="RE_St" id="homeOwnership">
                                </select>
                                <select name="" class="RE_St" id="homeOwnershipcity">
                                </select>
                            </td>
                          </tr>
                        </table>
                    </td>
                  </tr>
                  <tr>
                    <td align="right">银行卡号</td>
                    <td><input type="text" class="RE1_t2" id="bankCard"/></td>
                  </tr>
                  <tr>
                    <td align="right">&nbsp;</td>
                    <td>
                    	<input type="submit" value="下一步" class="RS_go"  onclick="nextStep()" />
                    </td>
                  </tr>
                </table>
            </div>
            
        </div>
    </div>
    
    <div class="Footer">
    	<div class="width1200">
        	<div class="left">版权所有：中国福利彩票发行管理中心    网站主办：中国福利彩票发行管理中心</div>
            <div class="right"><img src="images/Flogo.png" width="110" /></div>
            <div class="clear"></div>
        </div>
    </div>
    
</body>

<script type="text/javascript">
var accountId="";
var token="";
var channelId="";
var password="";
//点击“下一步”执行  
function nextStep() {
	 //验证身份证
	if(!validateIDCard('idCard')){
		return;
	}
	 //验证姓名
	if(!validateName('name')){
		return;
	}
	//验证银行卡号
	if(!validateBankNum('bankCard')){
		return;
	}
  var para = {
		  	bankCard:$('#bankCard').val(),
			regionCode:$('#homeOwnership').val()+"_"+$('#homeOwnershipcity').val(),
			swiftCode:$('#bank').val(),
			name:$('#name').val(),
			idCard:$('#idCard').val(),
			sex:$('#sex').val(),
			accountId:accountId,
			token:token,
			password:password,
			channelId:channelId
        };
	
	$.ajax({
		url : "../../api/CrmSystem/register/authentication",
		async:false,
		type : "POST",
		herder:{
			'Accept':'application/json',
			'Content-Type':'application/json'
		},
		dataType:"json",
		contentType:"application/json",
		data: JSON.stringify(para),
		error:function(XMLHttpRequest, textStatus, errorThrown){
			alert(errorThrown);
		},
		success: function(data, textStatus){
// 			var obj = eval("("+data+")"); 
			if(data.success == true){
				window.location.href='Register2.html';
			}else{
				alert("error:"+data.description);
				return;
			}
		}		
	});
} 



function load(){
	accountId = getCookie("accountId");
	token = getCookie("token");
	channelId = getCookie("channelId");
	password = GetQueryString("password");
	//调用接口查询 银行类别
	$.ajax({
		url : "../../api/CrmSystem/para/swiftcode",
		async:false,
		type : "GET",
		herder:{
			'Accept':'application/json',
			'Content-Type':'application/json'
		},
		dataType:"json",
		contentType:"application/json",
		error:function(XMLHttpRequest, textStatus, errorThrown){
			alert(errorThrown);
		},
		success: function(data, textStatus){
			document.getElementById("bank").options.length=0;
// 			var data = "[{\"swiftCode\": \"AK\",\"swiftName\": \"安徽省农村信用社\",\"marks\": null},{\"swiftCode\": \"AZ\",\"swiftName\": \"长安银行\",\"marks\": null}]";
// 			var obj = eval("("+data+")"); 
			for(var i=0;i<data.length;i++){
				document.getElementById("bank").options.add(new Option(data[i].swiftName,data[i].swiftCode));
			}
		}		
	});
	//调用地区参数查询接口
	getFirstLevel();
	getSecondLevel($('#homeOwnership').val());
	
	//归属地第一级改变出发的事件
	$("#homeOwnership").change(function(){
		getSecondLevel($('#homeOwnership').val());
		});
	
	
}

//获得归属地--第一级
function getFirstLevel(){
	$.ajax({
		url : "../../api/CrmSystem/para/region?pid=0",
		async:false,
		type : "GET",
		herder:{
			'Accept':'application/json',
			'Content-Type':'application/json'
		},
		dataType:"json",
		contentType:"application/json",
		error:function(XMLHttpRequest, textStatus, errorThrown){
			alert(errorThrown);
		},
		success: function(data, textStatus){
			document.getElementById("homeOwnership").options.length=0;
			for(var i=0;i<data.length;i++){
				document.getElementById("homeOwnership").options.add(new Option(data[i].regionName,data[i].id));
			}
		}		
	});
}
//获得归属地--第二级
function getSecondLevel(pid){
	if(pid==null){
		pid=0;
	}
	$.ajax({
		url : "../../api/CrmSystem/para/region?pid="+pid+"",
		async:false,
		type : "GET",
		herder:{
			'Accept':'application/json',
			'Content-Type':'application/json'
		},
		dataType:"json",
		contentType:"application/json",
		error:function(XMLHttpRequest, textStatus, errorThrown){
			alert(errorThrown);
		},
		success: function(data, textStatus){
			document.getElementById("homeOwnershipcity").options.length=0;
			for(var i=0;i<data.length;i++){
				document.getElementById("homeOwnershipcity").options.add(new Option(data[i].regionName,data[i].id));
			}
		}		
	});
}


</script>
<script src="js/common.js"></script>
<script src="js/jsCallCookies.js"></script>
<script src="js/validation.js"></script>
</html>
